'''
@File    :   SessionControl_0x10_test.py
@Time    :   2024/08/27 13:31:28
@Author  :   YangLiang 
@Version :   1.0
@Contact :   yangliang@chengtech.com
@License :   (C)Copyright 2022-2025
@Desc    :   None
'''

from pytest_assume.plugin import assume

import pytest
import logging
import time
from sympy import I
# from sympy import assuming
from commDriver.TS_CAN import *
import allure
import sys
from collections.abc import Iterable

from sqlalchemy import false
sys.dont_write_bytecode = True

'''会话切换'''
SessionControl_Default = [  ([0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x81], []),
                            ([0x10, 0x83], []),
                        ]

SessionControl_Boot = [     ([0x10, 0x02], [0x50, 0x02, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x82], []),
                            ([0x10, 0x83], []),
                        ]

SessionControl_Extended = [ ([0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x02], [0x50, 0x02, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8]),
                            ([0x10, 0x81], []),
                            ([0x10, 0x82], []),
                            ([0x10, 0x83], []),     
                        ]

'''NRC7E'''
SessionControl_Boot_NRC7E = [   ([0x10, 0x03], [0x7F, 0x10, 0x7E]),
                                ([0x10, 0x83], []),
                            ]

SessionControl_Default_NRC7E = [    ([0x10, 0x02], [0x7F, 0x10, 0x7E]),
                                    ([0x10, 0x82], [0x7F, 0x10, 0x7E]),
                            ]

'''NRC12'''
SessionControl_NRC12 = [    ([0x10, 0x04], [0x7F, 0x10, 0x12]),
                            ([0x10, 0x05], [0x7F, 0x10, 0x12]),
                            ([0x10, 0x06], [0x7F, 0x10, 0x12]),
                            ([0x10, 0x84], [0x7F, 0x10, 0x12]),
                            ([0x10, 0x85], [0x7F, 0x10, 0x12]),
                            ([0x10, 0x86], [0x7F, 0x10, 0x12]),
                        ]
'''NRC13'''
SessionControl_NRC13 = [    ([0x10], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x01, 0x02], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x02, 0x03], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x03, 0x02], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x01, 0xFF], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x02, 0xFF], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x03, 0x10], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x05, 0x06], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x81, 0xFF], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x82, 0xFF], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x83, 0x10], [0x7F, 0x10, 0x13]),
                            ([0x10, 0x85, 0x06], [0x7F, 0x10, 0x13]),
                        ]

'''NRC11'''
SessionControl_NRC11 = [    ([0x23], [0x7F, 0x23, 0x11]),
                            ([0x2A], [0x7F, 0x2A, 0x11]),
                            ([0x2C], [0x7F, 0x2C, 0x11]),
                            ([0x2F], [0x7F, 0x2F, 0x11]),
                        ]

class Test_SessionControl_Phy_App(object):

    @allure.severity('normal')
    @allure.story('Session Control Test')
    @allure.title('Test repeat five count session change [1001->1003] with with physical addressing for 0x10')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @allure.description('Test session change session in 1001->1003')
    def test_sessionSwitch1_Phy(self, action, Driver):
        iStep = 1
        for i in range(5):
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
  

    @allure.severity('normal')
    @allure.title('Test session change [1001->1003->1101] with with physical addressing for 0x10')
    @allure.description('Test session change from 1001->1003->1101')
    def test_sessionSwitch2_Phy(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11, 0x01], [0x51, 0x01], 0, iStep, False)


    @allure.severity('normal')
    @allure.title('Test session change [1001->1003->1103->1101] with with physical addressing for 0x10')
    @allure.description('Test session change from 1001->1003->1103->1101')
    def test_sessionSwitch3_Phy(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11, 0x03], [0x51, 0x03], 0, iStep, False)
        time.sleep(2)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11, 0x01], [0x51, 0x01], 0, iStep, False)
        time.sleep(2)


    @allure.severity('normal')
    @allure.title('Test session change [1001->1003->1002->restart->22F186] with with physical addressing for 0x10')
    @allure.description('Test session change from 1001->1003->1101')
    def test_sessionSwitch4_Phy(self, action, Driver):
        iStep = 1
        for i in range(1):
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x31, 0x01, 0x02, 0x03], [0x71, 0x01], 0, iStep, False)
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02], [0x50, 0x02, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False)
            time.sleep(0.5)
            iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            with allure.step(f'Step{iStep}:wait 4s'):
                time.sleep(4)
                iStep += 1
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02], [0x7F, 0x10, 0x22], 0, iStep, False)




    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_Default]
    @allure.severity('normal')
    @allure.title('Test {req} in default session with with physical addressing for 0x10')
    @allure.description('Test positive response of SID 0x10 in default session with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_Default, ids=ids)
    def test_sessionControl_Default_Phy(self, action,  Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)

    
    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_Extended]
    @allure.severity('normal')
    @allure.title('Test {req} in extended session with with physical addressing for 0x10')
    @allure.description('Test positive response of SID 0x10 in extended session with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_Extended, ids=ids)
    def test_sessionControl_Extended_Phy(self, action,  Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '71 01', 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 0, iStep, False)


    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC11]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC11 in default session with with physical addressing for 0x10')
    @allure.description('Test NRC11 of SID 0x10 in default sesison with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC11, ids=ids)
    def test_sessionControl_NRC11_Default_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)

    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC11]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC11 in extended session with with physical addressing for 0x10')
    @allure.description('Test NRC11 of SID 0x10 in extended sesison with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC11, ids=ids)
    def test_sessionControl_NRC11_Extended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    
    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC12]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC12 in default session with with physical addressing for 0x10')
    @allure.description('Test NRC12 of SID 0x10 in default sesison with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC12, ids=ids)
    def test_sessionControl_NRC12_Default_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)

    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC12]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC12 in extended session with with physical addressing for 0x10')
    @allure.description('Test NRC12 of SID 0x10 in extended sesison with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC12, ids=ids)
    def test_sessionControl_NRC12_Extended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)


    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC13]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC13 in default session with with physical addressing for 0x10')
    @allure.description('Test NRC13 of SID 0x10 in default sesison with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC13, ids=ids)
    def test_sessionControl_NRC13_Default_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)

    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC13]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC13 in extended session with with physical addressing for 0x10')
    @allure.description('Test NRC13 of SID 0x10 in extended sesison with physical addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC13, ids=ids)
    def test_sessionControl_NRC13_Extended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)


    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_Default_NRC7E]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC7E in extended session with physical addressing for 0x10')
    @allure.description('Test NRC7E in extended session with physical addressing for 0x10')
    @pytest.mark.parametrize('req,resp', SessionControl_Default_NRC7E, ids=ids)
    def test_sessionControl_NRC7E_Default_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '71 01', 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)


    @allure.severity('minor')
    @allure.description('Test Test NRC Priority of 0x10 in extended session with physical addressing')
    def test_sessionControl_NRC_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        # 设置电压为17v，并等待1.5s
        iStep = Driver['CAN'].SetVolt(Driver, 17, 1.5, iStep)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02, 0x00], [0x7F, 0x10, 0x13], 3, iStep, False)
        # 设置电压为12v，并等待1.5s
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)


    @allure.severity('minor')
    @allure.description('Test Test NRC22 of 0x10 in extended session with physical addressing')
    def test_sessionControl_NRC22_Extended_Phy(self, action, Driver):
        iStep = 1
        # 设置电压为17v，并等待1.5s
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x31, 0x01,0x02,0x03], [0x71, 0x01], 3, iStep, False,'UDS')
        iStep = Driver['CAN'].SetVolt(Driver, 17, 1.5, iStep)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02], [0x7F, 0x10, 0x22], 0, iStep, False)
        # 设置电压为12v，并等待1.5s
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

    
    @allure.severity('normal')
    @allure.title('Test session change [1001->1001] with with physical addressing for 0x10')
    @allure.description('Test session change from 1001->1001')
    def test_sessionSwitch_repeat_Phy(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '1001', '5001', 0, iStep, False)
        time.sleep(0.5)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '1003', '5003', 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31010203', '71010203', 0, iStep, False)
        for i in range(3):
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '1001', '5001', 0, iStep, False)
            time.sleep(0.5)
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '1003', '5003', 0, iStep, False)
            time.sleep(0.5)
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31010203', '71010203', 0, iStep, False)
            time.sleep(0.5)
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '1002', '5002', 0, iStep, False)



class Test_SessionControl_Fun_App(object):
    '''
    test SessionControl with Functional address in APP mode
    '''
    @allure.severity('normal')
    @allure.story('Session Control Test')
    @allure.title('Test repeat five count session change [1001->1003] with with functional addressing for 0x10')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @allure.description('Test session change session in 1001->1003')
    def test_sessionSwitch1_Fun(self, action, Driver):
        iStep = 1
        for i in range(5):
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
  

    @allure.severity('normal')
    @allure.title('Test session change [1001->1003->1101] with with functional addressing for 0x10')
    @allure.description('Test session change from 1001->1003->1101')
    def test_sessionSwitch2_Fun(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11, 0x01], [0x51, 0x01], 0, iStep, False,'UDSFun')


    @allure.severity('normal')
    @allure.title('Test session change [1001->1003->1103->1101] with with functional addressing for 0x10')
    @allure.description('Test session change from 1001->1003->1103->1101')
    def test_sessionSwitch3_Fun(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x01], [0x50, 0x01, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11, 0x03], [0x51, 0x03], 0, iStep, False,'UDSFun')
        time.sleep(2)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11, 0x01], [0x51, 0x01], 0, iStep, False,'UDSFun')
        time.sleep(2)


    @allure.severity('normal')
    @allure.title('Test session change [1001->1003->1002->restart->22F186] with with functional addressing for 0x10')
    @allure.description('Test session change from 1001->1003->1101')
    def test_sessionSwitch4_Fun(self, action, Driver):
        iStep = 1
        for i in range(1):
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x03], [0x50, 0x03, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '71 01', 0, iStep, False,'UDS')
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02], [0x50, 0x02, 0x00, 0x32, 0x00, 0xC8], 0, iStep, False,'UDSFun')
            time.sleep(0.5)
            iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            with allure.step(f'Step{iStep}:wait 4s'):
                time.sleep(4)
                iStep += 1
            iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02], [0x7F, 0x10, 0x22], 0, iStep, False,'UDSFun')




    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_Default]
    @allure.severity('normal')
    @allure.title('Test {req} in default session with with functional addressing for 0x10')
    @allure.description('Test positive response of SID 0x10 in default session with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_Default, ids=ids)
    def test_sessionControl_Default_Fun(self, action,  Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False,'UDSFun')

    
    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_Extended]
    @allure.severity('normal')
    @allure.title('Test {req} in extended session with with functional addressing for 0x10')
    @allure.description('Test positive response of SID 0x10 in extended session with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_Extended, ids=ids)
    def test_sessionControl_Extended_Fun(self, action,  Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '71 01', 3, iStep, False,'UDS')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 0, iStep, False,'UDSFun')


    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC11]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC11 in default session with with functional addressing for 0x10')
    @allure.description('Test NRC11 of SID 0x10 in default sesison with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC11, ids=ids)
    def test_sessionControl_NRC11_Default_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, '', 1, iStep, False,'UDSFun')

    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC11]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC11 in extended session with with functional addressing for 0x10')
    @allure.description('Test NRC11 of SID 0x10 in extended sesison with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC11, ids=ids)
    def test_sessionControl_NRC11_Extended_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, '', 3, iStep, False,'UDSFun')

    
    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC12]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC12 in default session with with functional addressing for 0x10')
    @allure.description('Test NRC12 of SID 0x10 in default sesison with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC12, ids=ids)
    def test_sessionControl_NRC12_Default_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, '', 1, iStep, False,'UDSFun')

    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC12]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC12 in extended session with with functional addressing for 0x10')
    @allure.description('Test NRC12 of SID 0x10 in extended sesison with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC12, ids=ids)
    def test_sessionControl_NRC12_Extended_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, '', 3, iStep, False,'UDSFun')


    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC13]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC13 in default session with with functional addressing for 0x10')
    @allure.description('Test NRC13 of SID 0x10 in default sesison with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC13, ids=ids)
    def test_sessionControl_NRC13_Default_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False,'UDSFun')

    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_NRC13]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC13 in extended session with with functional addressing for 0x10')
    @allure.description('Test NRC13 of SID 0x10 in extended sesison with functional addressing')
    @pytest.mark.parametrize('req,resp', SessionControl_NRC13, ids=ids)
    def test_sessionControl_NRC13_Extended_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False,'UDSFun')


    ids = ["Request {}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in SessionControl_Default_NRC7E]
    @allure.severity('minor')
    @allure.title('Test {req} of NRC7E in default session with functional addressing for 0x10')
    @allure.description('Test NRC7E in default session with functional addressing for 0x10')
    @pytest.mark.parametrize('req,resp', SessionControl_Default_NRC7E, ids=ids)
    def test_sessionControl_NRC7E_Default_Fun(self, action, Driver, req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '71 01', 3, iStep, False,'UDS')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, '', 1, iStep, False,'UDSFun')


    @allure.severity('minor')
    @allure.description('Test Test NRC Priority of 0x10 in extended session with functional addressing')
    def test_sessionControl_NRC_Priority_Extended_Fun(self, action, Driver):
        iStep = 1
        # 设置电压为17v，并等待1.5s
        iStep = Driver['CAN'].SetVolt(Driver, 17, 1.5, iStep)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02, 0x00], [0x7F, 0x10, 0x13], 3, iStep, False,'UDSFun')
        # 设置电压为12v，并等待1.5s
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)


    @allure.severity('minor')
    @allure.description('Test Test NRC22 of 0x10 in Extended session with functional addressing')
    def test_sessionControl_NRC22_Extended_Fun(self, action, Driver):
        iStep = 1
        # 设置电压为17v，并等待1.5s
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x31, 0x01,0x02,0x03], [0x71, 0x01], 3, iStep, False,'UDS')
        iStep = Driver['CAN'].SetVolt(Driver, 17, 1.5, iStep)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10, 0x02], [0x7F, 0x10, 0x22], 0, iStep, False,'UDSFun')
        # 设置电压为12v，并等待1.5s
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)